package model.semantics;

import java.util.List;

import model.State;
import model.TurtleState;

public class AskNode extends Node<Integer> {
    private AggregatorNode<Integer> myArguments;
    private AggregatorNode<Integer> myCommands;

    public AskNode(AggregatorNode<Integer> argument,
            AggregatorNode<Integer> commands) {
        myArguments = argument;
        myCommands = commands;
    }

    @Override
    public Integer evaluate(State<Integer> state) {
        int rtn = 0;
        List<Integer> activeTurtles = ((TurtleState) state).getActiveTurtles();
        List<Integer> turtles = myArguments.evaluateList(state);
        ((TurtleState) state).setTurtles(turtles);
        rtn = myCommands.evaluate(((TurtleState) state));
        ((TurtleState) state).setTurtles(activeTurtles);
        return rtn;

    }
}
